﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MonitoringPlanSite.Master" AutoEventWireup="true" 
    CodeBehind="Default.aspx.cs" Inherits="Amkeni_Monitoring_Plan.Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

    <%--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" />
    <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>--%>

    <script type="text/javascript">
        $(document).ready(function () {
            $('[class^="filter"]').click(function () {

                var pos = $(this).position();
                var width = $(this).outerWidth();
                var height = $(this).outerHeight();
                var colName = $(this).attr("alt");
                var hiddenControlValue = $('#MainContent_hndSelectedValue').val();

                jQuery.support.cors = true;

                $.ajax({

                    type: "GET",
                    url: "Service1.svc/data?ColumnName=" + colName + "&AlreadySelectedValue=" + hiddenControlValue,
                    processData: false,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    data: "{}",

                    success: function (response) {

                        var filterdiv = $("<div id='divFilterList'></div>");
                        var div = $("<div></div>");
                        var valuesdiv = $("<div id='filterChkBox'></div>");
                        var table = $("<table />");
                        var SelectedValue = {};

                        if (hiddenControlValue.length > 0) {
                            var alreadySelectedValueInfo = jQuery.parseJSON(hiddenControlValue);
                            for (var index = 0; index < alreadySelectedValueInfo.DataCollection.length; index++) {
                                if (alreadySelectedValueInfo.DataCollection[index].ColumnName == colName) {
                                    SelectedValue = alreadySelectedValueInfo.DataCollection[index].SelectedValue;
                                }
                            }
                        }

                        $.each(response, function (index, obj) {
                            var IsSelected = false;
                            for (var index = 0; index < SelectedValue.length; index++) {
                                if (SelectedValue[index] == obj.Id)
                                    IsSelected = true;
                            }

                            if (IsSelected == true)
                                table.append("<tr><td><input name='options' checked='checked' type='checkbox' value='" + obj.Id + "'>" + obj.Value + "</td></tr>");
                            else
                                table.append("<tr><td><input name='options' type='checkbox' value='" + obj.Id + "'>" + obj.Value + "</td></tr>");
                        });

                        valuesdiv.append(table);
                        div.append(valuesdiv);
                        filterdiv.append(div);
                        $('body').append(filterdiv);

                        var buttondiv = $("<div></div>").css({
                            textAlign: "right",
                            paddingTop: "5px",
                            paddingRight: "5px"
                        }).show();

                        var clearFilterBtn = $("<button>.</button>");
                        clearFilterBtn.css(
                        {
                            height: "22px",
                            width: "25px",
                            border: "none",
                            background: "url(Images/ClearFilter.png) center center no-repeat",
                            cursor: "pointer"
                        });
                        buttondiv.append(clearFilterBtn);

                        var okBtn = $("<button>OK</button>");
                        okBtn.css({ height: "22px", width: "70px" });
                        buttondiv.append(okBtn);

                        var cancelBtn = $("<button>Cancel</button>");
                        cancelBtn.css({ height: "22px", width: "70px" });
                        buttondiv.append(cancelBtn);

                        cancelBtn.click(function () {
                            var container = $("#divFilterList");
                            container.detach();
                        });

                        okBtn.click(function () {

                            var SelectedDataCollection = {};

                            var ArrSelectedColumnsInfo = new Array(); // It holds all column selected info

                            var SelectedData = {};
                            SelectedData["ColumnName"] = colName;

                            var ArrSelectedValue = new Array();
                            $('#filterChkBox table tr td input:checked').each(function () {
                                ArrSelectedValue.push($(this).val());
                            });
                            SelectedData["SelectedValue"] = ArrSelectedValue;

                            var IsExist = false;
                            var alreadySelectedValueInfo;

                            if (hiddenControlValue.length > 0) {
                                var alreadySelectedValueInfo = jQuery.parseJSON(hiddenControlValue);
                                for (var index = 0; index < alreadySelectedValueInfo.DataCollection.length; index++) {
                                    if (alreadySelectedValueInfo.DataCollection[index].ColumnName == colName) {
                                        alreadySelectedValueInfo.DataCollection[index] = SelectedData;
                                        SelectedDataCollection = alreadySelectedValueInfo;

                                        IsExist = true;
                                        break;
                                    }
                                }
                            }

                            if (IsExist == false) {
                                var alreadySelectedValueInfo = new Array();
                                if (hiddenControlValue.length > 0) {
                                    alreadySelectedValueInfo = jQuery.parseJSON(hiddenControlValue);
                                    if (SelectedData.SelectedValue.length > 0) {
                                        alreadySelectedValueInfo["DataCollection"].push(SelectedData);
                                    }
                                    SelectedDataCollection = alreadySelectedValueInfo;
                                }
                                else {
                                    alreadySelectedValueInfo.push(SelectedData);
                                    SelectedDataCollection["DataCollection"] = alreadySelectedValueInfo;
                                }
                            }

                            $('#<%= hndSelectedValue.ClientID %>').val(JSON.stringify(SelectedDataCollection));
                            document.getElementById('<%= Refresh.ClientID %>').click(); //PLEASE KEEP IN MIND
                        });

                        clearFilterBtn.click(function () {
                            if (hiddenControlValue.length > 0) {
                                var alreadySelectedValueInfo = jQuery.parseJSON(hiddenControlValue);
                                alreadySelectedValueInfo.DataCollection = jQuery.grep(alreadySelectedValueInfo.DataCollection, function (value) {
                                    return value.ColumnName != colName;
                                });

                                $('#<%= hndSelectedValue.ClientID %>').val(JSON.stringify(alreadySelectedValueInfo));

                                //for (var index = 0; index < alreadySelectedValueInfo.DataCollection.length; index++) {
                                //    if (alreadySelectedValueInfo.DataCollection[index].ColumnName == colName) {
                                //        alreadySelectedValueInfo.DataCollection[index].selectedValue = new Array();
                                //        $('#<%= hndSelectedValue.ClientID %>').val(JSON.stringify(alreadySelectedValueInfo));
                                //        break;
                                //    }
                                //}
                            }
                            document.getElementById('<%= Refresh.ClientID %>').click(); //ISSUE TO CHECK OUT
                        });

                        filterdiv.append(buttondiv);

                        var tblwidth = table.outerWidth();
                        valuesdiv.css({ width: tblwidth + "px" }).show();

                        div.css(
                        {
                            overflow: "auto",
                            textAlign: "left",
                            paddingLeft: "5px",
                            paddingTop: "1px",
                            marginLeft: "1px",
                            marginTop: "1px",
                            backgroundColor: "White",
                            border: "1px solid gray",
                            height: "207px",
                            width: "200px"
                        }).show();

                        var left = 0;
                        if (pos.left + width - 200 - 10 < 0)
                            left = 0;
                        else
                            left = pos.left + width - 200 - 10;

                        filterdiv.css(
                        {
                            position: "absolute",
                            textAlign: "left",
                            backgroundColor: "white",
                            border: "1px solid black",
                            color: "black",
                            height: "243px",
                            width: "209px",
                            top: pos.top + height + 1 + "px",
                            left: left + "px"
                        }).show();
                    },
                    error: function (xhr, status, error) {
                        alert("FAIL :" + xhr + " " + status + " " + error);
                    }
                });
            });
            $(document).mouseup(function (e) {
                var container = $("#divFilterList");

                if (container.has(e.target).length === 0) {
                    container.detach();
                }
            });
        });
    </script>

    <style type="text/css">
        th.filter
        {
            background: url(Images/ShowFilter.png) right center no-repeat;
            cursor:pointer;
            padding: 4px 2px;
            color: #fff;
            background-color: #0055cc;
            border-left: solid 1.5px #FFFFFF;
            font-weight:600;
        }
        th.filterExist
        {
            background: url(Images/FilterExist.png) right center no-repeat;
            cursor:pointer;
            padding: 4px 2px;
            color: #fff;
            background-color: #0055cc;
            border-left: solid 1.5px #FFFFFF;
            font-weight:600;
        }
        .tooltip
        {
            border:2px solid #317082;	/* Border width */
            left:18px;	/* Same as border thickness */
            top:0px;
            position:absolute;
            width:300px;	 /*Width of tooltip content */
            /*height:100px;	/* Height of tooltip content */
            background-color:#FFF;	/* Background color */
            padding:5px;	/* Space between border and content */
            font-size:1.0em;	/* Font size of content */
            overflow:auto;	/* Hide overflow content */
            z-index:1000001;
        }
    </style>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

    <div id="divFilter"></div>

    <% if(User.IsInRole("IP"))
       { %>
    <asp:GridView ID="IPMonitoringPlanGridView" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="monitoring_plan_id,ip_id" CssClass="NewGrid" ShowFooter="True">
        <AlternatingRowStyle CssClass="NewGridAlt" />
        <FooterStyle CssClass="NewGridFooter" />
        <Columns>
            <asp:TemplateField HeaderText="monitoring_plan_id" SortExpression="monitoring_plan_id" Visible="false">
                <ItemTemplate>
                    <asp:Label ID="IDLabel" runat="server" Text='<%# Bind("monitoring_plan_id") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Call" HeaderText="Call" SortExpression="Call" />
            <asp:TemplateField HeaderText="IP" SortExpression="abbreviation">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("abbreviation") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="IPLabel" runat="server" Text='<%# Eval("abbreviation") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Year" SortExpression="year">
                <ItemTemplate>
                    <asp:Label ID="YrLabel" runat="server" Text='<%# Eval("year") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Outcome" SortExpression="outcome_id">
                <ItemTemplate>
                    <asp:Label ID="OutcomeLabel" runat="server" Text='<%# Eval("outcome_id") %>'></asp:Label>
                    <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="OutcomeLabel"
                        PopupControlID="OutcomeLabelToolTip" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                    <asp:Label ID="OutcomeLabelToolTip" runat="server" Text='<%# Eval("outcome_name") %>' CssClass="tooltip"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Output" SortExpression="output_id">
                <ItemTemplate>
                    <asp:Label ID="OutputLabel" runat="server" Text='<%# Eval("output_id") %>'></asp:Label>
                    <asp:HoverMenuExtender ID="HoverMenuExtender2" runat="server" TargetControlID="OutputLabel"
                        PopupControlID="OutputLabelToolTip" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                    <asp:Label ID="OutputLabelToolTip" runat="server" Text='<%# Eval("output_name") %>' CssClass="tooltip"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="activity" HeaderText="Activity" SortExpression="activity" />
            <asp:TemplateField HeaderText="Output Indicator" SortExpression="output_indicator_id">
                <ItemTemplate>
                    <asp:Label ID="IndicatorLabel1" runat="server" 
                        Text='<%# indicatorID(Eval("indicator_id").ToString()) %>'></asp:Label>
                    <asp:HoverMenuExtender ID="HoverMenuExtender3" runat="server" TargetControlID="IndicatorLabel1"
                        PopupControlID="IndicatorLabelToolTip1" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                    <asp:Label ID="IndicatorLabelToolTip1" runat="server" Text='<%# Eval("indicator_name") %>' CssClass="tooltip"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="baseline" HeaderText="Baseline" SortExpression="baseline" />
            <asp:BoundField DataField="target" HeaderText="Target" SortExpression="target" />
            <asp:BoundField DataField="programme_officer" HeaderText="Programme Analyst" SortExpression="programme_officer" />
            <asp:BoundField DataField="ip_officer" HeaderText="IP Officer" SortExpression="ip_officer" />
            <asp:BoundField DataField="data_source" HeaderText="Data Source" SortExpression="data_source" />
            <asp:BoundField DataField="method_of_collection" HeaderText="Collection Method" SortExpression="method_of_collection" />
            <asp:BoundField DataField="collection_tools" HeaderText="Collection Tools" SortExpression="collection_tools" />
            <asp:TemplateField HeaderText="Q1" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox1"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox1" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Q2" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox2"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox2" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Q3" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox3"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox3" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Q4" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox4"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox4" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <%--<asp:TemplateField>
                <ItemTemplate>
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="monitoring_data_frequency_id">
                        <Columns>
                            <asp:BoundField DataField="monitoring_data_frequency_id" HeaderText="monitoring_data_frequency_id" SortExpression="monitoring_data_frequency_id" ReadOnly="True" Visible="false"></asp:BoundField>
                            <asp:BoundField DataField="monitoring_plan_id" HeaderText="monitoring_plan_id" SortExpression="monitoring_plan_id"></asp:BoundField>
                            <asp:BoundField DataField="report_period_id" HeaderText="report_period_id" SortExpression="report_period_id"></asp:BoundField>
                        </Columns>
                    </asp:GridView>
                </ItemTemplate>
            </asp:TemplateField>--%>
            <asp:BoundField DataField="resource_required" HeaderText="Resource Required" SortExpression="resource_required"
                DataFormatString="Ksh {0:N2}" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="assumptions_and_risks" HeaderText="Assumptions & Risks" SortExpression="assumptions_and_risks" />
            <asp:BoundField DataField="means_of_verification" HeaderText="Means Of Verification" SortExpression="means_of_verification" />
            <asp:TemplateField>
                <ItemTemplate>
                    <%--<asp:LinkButton ID="LinkButton1" runat="server" class="btn btn-primary" 
                        data-toggle="modal" data-target=".modal_edit" 
                        CommandArgument='<%# Eval("monitoring_plan_id") %>' OnClick="LinkButton1_Click">Edit</asp:LinkButton>--%>
                    <asp:LinkButton ID="EditButton" runat="server" 
                        CommandArgument='<%# Eval("monitoring_plan_id") %>' 
                        OnClick="EditButton_Click">Edit</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="DelBtn" runat="server" OnClientClick="return confirm('Are you sure you want to delete this data?')"
                        OnClick="DelBtn_Click" CommandArgument='<%# Eval("monitoring_plan_id") %>'>Delete</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <% }
       else
       { %>
    <asp:GridView ID="MonitoringGridView" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="monitoring_plan_id" CssClass="NewGrid" ShowFooter="True" 
        OnRowEditing="MonitoringGridView_RowEditing">
        <AlternatingRowStyle CssClass="NewGridAlt" />
        <FooterStyle CssClass="NewGridFooter" />
        <Columns>
            <asp:TemplateField HeaderText="monitoring_plan_id" SortExpression="monitoring_plan_id" Visible="false">
                <ItemTemplate>
                    <asp:Label ID="IDLabel" runat="server" Text='<%# Bind("monitoring_plan_id") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Call" HeaderText="Call" SortExpression="Call" />
            <asp:TemplateField HeaderText="IP" SortExpression="abbreviation">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("abbreviation") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="IPLabel" runat="server" Text='<%# Eval("abbreviation") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Year" SortExpression="year">
                <ItemTemplate>
                    <asp:Label ID="YrLabel" runat="server" Text='<%# Eval("year") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <%--<asp:BoundField DataField="outcome_id" HeaderText="Outcome" SortExpression="outcome_id" />--%>
            <asp:TemplateField HeaderText="Outcome" SortExpression="outcome_id">
                <ItemTemplate>
                    <asp:Label ID="OutcomeLabel" runat="server" Text='<%# Eval("outcome_id") %>'></asp:Label>
                    <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="OutcomeLabel"
                        PopupControlID="OutcomeLabelToolTip" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                    <asp:Label ID="OutcomeLabelToolTip" runat="server" Text='<%# Eval("outcome_name") %>' CssClass="tooltip"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <%--<asp:BoundField DataField="output_id" HeaderText="Output" SortExpression="output_id" />--%>
            <asp:TemplateField HeaderText="Output" SortExpression="output_id">
                <ItemTemplate>
                    <asp:Label ID="OutputLabel" runat="server" Text='<%# Eval("output_id") %>'></asp:Label>
                    <asp:HoverMenuExtender ID="HoverMenuExtender2" runat="server" TargetControlID="OutputLabel"
                        PopupControlID="OutputLabelToolTip" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                    <asp:Label ID="OutputLabelToolTip" runat="server" Text='<%# Eval("output_name") %>' CssClass="tooltip"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="activity" HeaderText="Activity" SortExpression="activity" />
            <%--<asp:BoundField DataField="output_indicator_id" HeaderText="Output Indicator" SortExpression="output_indicator_id" />--%>
            <asp:TemplateField HeaderText="Output Indicator" SortExpression="output_indicator_id">
                <ItemTemplate>
                    <asp:Label ID="IndicatorLabel1" runat="server" 
                        Text='<%# indicatorID(Eval("indicator_id").ToString()) %>'></asp:Label>
                    <asp:HoverMenuExtender ID="HoverMenuExtender3" runat="server" TargetControlID="IndicatorLabel1"
                        PopupControlID="IndicatorLabelToolTip1" OffsetX="0" OffsetY="20"></asp:HoverMenuExtender>
                    <asp:Label ID="IndicatorLabelToolTip1" runat="server" Text='<%# Eval("indicator_name") %>' CssClass="tooltip"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="baseline" HeaderText="Baseline" SortExpression="baseline" />
            <asp:BoundField DataField="target" HeaderText="Target" SortExpression="target" />
            <asp:BoundField DataField="programme_officer" HeaderText="Programme Analyst" SortExpression="programme_officer" />
            <asp:BoundField DataField="ip_officer" HeaderText="IP Officer" SortExpression="ip_officer" />
            <asp:BoundField DataField="data_source" HeaderText="Data Source" SortExpression="data_source" />
            <asp:BoundField DataField="method_of_collection" HeaderText="Collection Method" SortExpression="method_of_collection" />
            <asp:BoundField DataField="collection_tools" HeaderText="Collection Tools" SortExpression="collection_tools" />
            <asp:TemplateField HeaderText="Q1" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox1"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox1" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Q2" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox2"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox2" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Q3" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox3"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox3" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Q4" SortExpression="active">
                <EditItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox4"></asp:CheckBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="CheckBox4" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <%--<asp:TemplateField>
                <ItemTemplate>
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="monitoring_data_frequency_id">
                        <Columns>
                            <asp:BoundField DataField="monitoring_data_frequency_id" HeaderText="monitoring_data_frequency_id" SortExpression="monitoring_data_frequency_id" ReadOnly="True" Visible="false"></asp:BoundField>
                            <asp:BoundField DataField="monitoring_plan_id" HeaderText="monitoring_plan_id" SortExpression="monitoring_plan_id"></asp:BoundField>
                            <asp:BoundField DataField="report_period_id" HeaderText="report_period_id" SortExpression="report_period_id"></asp:BoundField>
                        </Columns>
                    </asp:GridView>
                </ItemTemplate>
            </asp:TemplateField>--%>
            <asp:BoundField DataField="resource_required" HeaderText="Resource Required" SortExpression="resource_required"
                DataFormatString="Ksh {0:N2}" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="assumptions_and_risks" HeaderText="Assumptions & Risks" SortExpression="assumptions_and_risks" />
            <asp:BoundField DataField="means_of_verification" HeaderText="Means Of Verification" SortExpression="means_of_verification" />
            <asp:TemplateField>
                <ItemTemplate>
                    <%--<asp:LinkButton ID="LinkButton1" runat="server" class="btn btn-primary" 
                        data-toggle="modal" data-target=".modal_edit" 
                        CommandArgument='<%# Eval("monitoring_plan_id") %>' OnClick="LinkButton1_Click">Edit</asp:LinkButton>--%>
                    <asp:LinkButton ID="EditButton" runat="server" 
                        CommandArgument='<%# Eval("monitoring_plan_id") %>' 
                        OnClick="EditButton_Click">Edit</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="DelBtn" runat="server" OnClientClick="return confirm('Are you sure you want to delete this data?')"
                        OnClick="DelBtn_Click" CommandArgument='<%# Eval("monitoring_plan_id") %>'>Delete</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <%--<asp:CommandField ShowEditButton="true" />--%>
        </Columns>
    </asp:GridView>
    <% } %>

    <%--<div class="modal fade modal_edit" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" 
        aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          This is a test...
            <asp:Label ID="Label2" runat="server" Text="Label" ForeColor="Red"></asp:Label>
        </div>
      </div>
    </div>--%>

    <asp:Button ID="Refresh" runat="server" Text="Refresh" OnClick="Refresh_Click" />
    <asp:HiddenField ID="hndSelectedValue" runat="server" Value="" />

</asp:Content>
